package cc.multivision.dao;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import cc.multivision.impl.LoginDaoImpl;
import cc.multivision.model.Login;

@Transactional
@Component (value="logindao")
public class LoginDao implements LoginDaoImpl{
	
	@Autowired
	@Qualifier("mysf")
	private SessionFactory mysf;
	
	
	@Override
	public boolean LoginTest(Login login) {
		Login user= (Login) mysf.getCurrentSession().createCriteria(Login.class).add(Restrictions.like("usr", login.getUsr())).uniqueResult();
		if (user!=null){
			if (user.getPass().equals(login.getPass())){
				return true;
			}
		}
		return false;
	}
	
	

}
